package com.ming.day250808;

import java.util.Random;
import java.util.Scanner;

public class a_array {
    public static void main(String[] args) {
        //动态初始化
        //int[] a = new int[5];
        //short[] b = new short[6];
        //long[] d = new long[8];
        //String[] c = new String[10];
        //char[] e = new char[5];
        //boolean[] f = new boolean[5];
        //byte[] g = new byte[5];
        //float[] h = new float[5];
        //double[] i = new double[5];
        //Object[] j = new Object[5];

        //静态初始化
        //int[] arr1 = {1,2,3,4,5};
        //String[] arr2 = {"顺治","康熙","雍正","乾隆","嘉庆","道光","咸丰","......"};
        //for(int x = 0; x < arr2.length; x++){
        //    System.out.print(arr2[x] + ",");
        //}
        //System.out.println();
        //System.out.println("数组长度:" + arr2.length);

        ////存储元素
        //int[] arr = new int[3];
        //arr[0] = 1;
        //arr[1] = 2;
        //arr[2] = 3;
        ////arr[3] = 4;//error
        //System.out.println(arr[0]);
        //System.out.println(arr[1]);
        //System.out.println(arr[2]);
        //
        //System.out.println("================");
        ////通过键盘录入的形式存数据
        //int[] arr2 = new int[3];
        //Scanner sc = new Scanner(System.in) ;
        ////arr2[0] = sc.nextInt();//键盘录入一个数存到arr2的o索引上
        ////arr2[1] = sc.nextInt();//键盘录入一个数存到arr2的1索引上
        ////arr2[2] = sc.nextInt();//键盘录入一个数存到arr2的2索引上
        //for (int i = 0; i < arr2.length; i++) {
        //   arr2[i] = sc.nextInt();
        //}
        //System.out.println(arr2[0]);
        //System.out.println(arr2[1]);
        //System.out.println(arr2[2]);
        //sc.close();

        //通过随机数存储数据
        int[] arr3 = new int[3];
        Random rd = new Random();
        for (int i = 0; i < arr3.length; i++) {
            arr3[i] = rd.nextInt(10);//随机生成10以内的数字
        }
        System.out.println(arr3[0]);
        System.out.println(arr3[1]);
        System.out.println(arr3[2]);
    }
}
